package com.haizhi.crm.biz.dao;

import com.haizhi.crm.biz.model.UserShareDo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by yangyijun on 2018/5/10.
 */
@Repository
public interface UserShareDao extends JpaRepository<UserShareDo, Long> {
    /**
     * 查询entitikey列表
     *
     * @param toUserIds
     * @param entityType
     */
    @Query(value = "select u.entityKey from UserShareDo u where u.toUserId in :toUserIds and u.entityType=:entityType" )
    List<String> findEntityKeys(@Param("toUserIds" ) List<Long> toUserIds, @Param("entityType" ) String entityType);

    UserShareDo findById(Long id);
}
